<template>
	<view class="page">
		<view class="feedback-body">
			<textarea auto-focus="true" placeholder="写下您举报的理由(字数20~150)..." v-model="content" class="feedback-textare" />
		</view>
		<view class="input-view">
			您好，收到您的举报之后，我们将对您的举报理由进行核实，如果举报属实，我们将会按照平台的约定，对该用户进行相关处理；
		</view>
		
		<button type="primary" class="feedback-submit" @tap="send">提交</button>
	</view>
</template><strong></strong>

<script>
	import {
		addAccusation
	} from '@/api/ucenter/index';
	import {mapGetters} from 'vuex';
	export default {
		data: {
			content:"",
			partyId: ""
		},
		onUnload(){
			this.content = ""
		},
		onLoad(e) {
			this.partyId = e.partyId;
		},
		computed: {
			...mapGetters(['userId'])
		},
		methods: {
			
			send() { //发送反馈
				if(this.content.length <=0 ||this.content.length < 20) {
					uni.showModal({
						title:"提示",
						content:"请至少输入20个字的描述，谢谢"
					})
					return;
				}
				
				let accusation= {
					partyId: this.partyId,
					accusationContent: this.content,
					createdBy: this.userId
				}
				addAccusation(accusation).then(response => {
					if(response.status == 200 && response.rel == true) {
						uni.showModal({
							title: "提示",
							content: "举报审批中，请等待平台反馈结果,谢谢您的举报",
							success: async function(){
								uni.navigateBack()
							}
						})
					}else {
						uni.showModal({
							title: "提示",
							content: "提交失败，请重试，谢谢",
							success: async function(){
								uni.navigateBack()
							}
						})
					}
				}).catch(err =>  {
					uni.showModal({
						title: "提示",
						content: "提交失败，请重试，谢谢",
						success: async function(){
							uni.navigateBack()
						}
					})
				});;
			}
		}
	}
</script>

<style>
	@import "../../common/uni.css";
	page {
		background-color: #EFEFF4;
	}

	.input-view {
		font-size: 28px;
	}
	
		
		.feedback-submit {
			background: #7C4BF9 !important;
		}
</style>
